<?php
if ( ! defined('EXT')) exit('Invalid file request');
 
class Yui_rte extends Fieldframe_Fieldtype {
 
  var $info = array(
    'name'             => 'YUI Rich Text Editor',
    'version'          => '1.2.0',
    'desc'             => 'Provides support for the YUI RTE',
    'docs_url'         => 'http://viewcreative.com'
  );
 
  var $hooks = array('publish_form_headers','publish_form_body_props');
 
 
 function publish_form_body_props() {
    global $DSP;
    
    $DSP->body_props .= ' class="yui-skin-sam"';

    return true;
   
 }
 
  function publish_form_headers()
  {
    $r = $this->get_last_call('') . NL . NL;

    $r .= '<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/assets/skins/sam/skin.css" />' . NL;
    $r .= '<script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>' . NL;
    $r .= '<script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/element/element-min.js"></script>' . NL;
    $r .= '<script src="http://yui.yahooapis.com/2.7.0/build/yahoo/yahoo-min.js"></script>' . NL;
    $r .= '<script src="http://yui.yahooapis.com/2.7.0/build/selector/selector-min.js"></script>' . NL;
    $r .= '<script src="http://yui.yahooapis.com/2.7.0/build/container/container_core-min.js"></script>' . NL;
    $r .= '<script src="http://yui.yahooapis.com/2.7.0/build/menu/menu-min.js"></script>' . NL;
    $r .= '<script src="http://yui.yahooapis.com/2.7.0/build/button/button-min.js"></script>' . NL;
    $r .= '<script src="http://yui.yahooapis.com/2.7.0/build/editor/editor-min.js"></script>' . NL . NL;
    
    return $r;
    
  }
 
   function display_field($field_name, $field_data)
   {
   global $DSP;

   $r =  '<script type="text/javascript">

     var myEditor = new YAHOO.widget.Editor("' . $field_name . '", { 
   	    height: "300px", 
   	    width: "99%", 
   	    dompath: true, 
   	    animate: true
   	  }); 
   	  
   	  

   	  myEditor.render(); 
 	 
   	  var nodes = YAHOO.util.Selector.query("input[type=submit]");  	
   	  YAHOO.util.Event.on(nodes, "click", function() { 
      	myEditor.saveHTML(); 
      });
 	 
    </script>';
    $r .= $DSP->input_textarea($field_name, $field_data);
    return $r;
  }
 
/* END class */
}
/* End of file ft.yui_rte.php */
/* Location: ./system/extensions/fieldtypes/yui_rte/ft.yui_rte.php */